package org.chen.common.translate.result;

import lombok.Data;

import java.io.Serializable;

@Data
public class ResultVO<T> implements Serializable {
    private Integer code;
    private Boolean success;
    private String message;
    private T data;
    
    public static <T> ResultVO<T> success(String message, T data) {
        ResultVO<T> result = new ResultVO<>();
        result.setCode(200);
        result.setSuccess(true);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static <T> ResultVO<T> success(T data) {
        ResultVO<T> result = new ResultVO<>();
        result.setCode(200);
        result.setSuccess(true);
        result.setMessage("操作成功");
        result.setData(data);
        return result;
    }

    public static <T> ResultVO<T> success() {
        ResultVO<T> result = new ResultVO<>();
        result.setCode(200);
        result.setSuccess(true);
        result.setMessage("操作成功");
        return result;
    }

    public static <T> ResultVO<T> success(String message) {
        ResultVO<T> result = new ResultVO<>();
        result.setCode(200);
        result.setSuccess(true);
        result.setMessage(message);
        return result;
    }
    
    public static <T> ResultVO<T> fail(String message) {
        ResultVO<T> result = new ResultVO<>();
        result.setCode(500);
        result.setSuccess(false);
        result.setMessage(message);
        return result;
    }

    public static <T> ResultVO<T> fail(T data) {
        ResultVO<T> result = new ResultVO<>();
        result.setCode(500);
        result.setSuccess(false);
        result.setMessage("操作失败");
        result.setData(data);
        return result;
    }

    public static <T> ResultVO<T> fail() {
        ResultVO<T> result = new ResultVO<>();
        result.setCode(500);
        result.setSuccess(false);
        result.setMessage("操作失败");
        return result;
    }
}